import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20190711.SmsClient;
import com.tencentcloudapi.sms.v20190711.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20190711.models.SendSmsResponse;
import org.junit.Test;

public class demo {

    @Test
    public static void main(String[] args) {
        try {
            Credential cred = new Credential("*", "*");
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("sms.tencentcloudapi.com");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);
            SmsClient client = new SmsClient(cred, "", clientProfile);
            //组装请求对象-具体描述见控制台-文档部分内容
            SendSmsRequest request = new SendSmsRequest();
            //必填:待发送手机号
            /*request.setPhoneNumbers("13877906666,13877907777,13877908888");*/
            String[] phone = {"+86199288888886"};
            request.setPhoneNumberSet(phone);
            //必填:短信签名-可在短信控制台中找到
            request.setSign("来场会谈公众号");
            //短信SdkAppid在 短信控制台 添加应用后生成的实际SdkAppid，示例如1400006666。
            request.setSmsSdkAppid("*");
            //必填:短信模板-可在短信控制台中找到
            request.setTemplateID("*");
            //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为String param = "{\"name\":\"张三\",\"code\":\"1234\"}";
            String[] param = {"1372"};
            request.setTemplateParamSet(param);
            SendSmsResponse resp = client.SendSms(request);
            System.out.println(SendSmsRequest.toJsonString(resp));
        } catch (TencentCloudSDKException e) {
            System.out.println(e.toString());
        }
    }
}
